package com.tebiecloud.base.server.controller.feign;

import com.tebiecloud.base.client.model.entity.BaseApp;
import com.tebiecloud.base.client.service.IBaseAppServiceClient;
import com.tebiecloud.base.server.service.BaseAppService;
import com.tebiecloud.common.model.ResultBody;
import com.tebiecloud.common.security.SecurityClientDetails;
import com.tebiecloud.common.utils.ResultBodyUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 系统应用管理
 * @Author: tebie
 * @Date: 2019-08-09 11:05
 */
@RestController
@RequestMapping("/feign/app")
public class AppController implements IBaseAppServiceClient {

    @Autowired
    private BaseAppService baseAppService;

    /**
     * 获取应用详情
     * @param appId
     * @return
     */
    @GetMapping("infoapp")
    @Override
    public ResultBody<BaseApp> getApp(
            @RequestParam("appId") String appId
    ) {
        BaseApp appInfo = baseAppService.getById(appId);
        return ResultBodyUtils.ok(appInfo);
    }

    /**
     * 获取应用开发配置信息
     * @param clientId
     * @return
     */
    @GetMapping("infoclientdetails")
    @Override
    public ResultBody<SecurityClientDetails> getClientDetails(
            @RequestParam("clientId") String clientId
    ) {
        SecurityClientDetails clientInfo = baseAppService.getClientDetails(clientId);
        return ResultBodyUtils.ok(clientInfo);
    }

}
